import smtplib

from config import *
from email.mime.text import MIMEText


class FalseEmail(object):
    def input_info(self, name, content):
        msg = MIMEText(content)
        msg["Subject"] = name
        msg["From"] = EMAIL_USER
        msg["To"] = EMAIL_TO
        return msg.as_string()

    def send_email(self, name, content):
        try:
            s = smtplib.SMTP_SSL(EMAIL_ADDRE, EMAIL_PORT)
            s.login(EMAIL_USER, EMAIL_PWD)
            s.sendmail(EMAIL_USER, EMAIL_TO, self.input_info(name, content))
            s.quit()
        except:
            return

if __name__ == '__main__':
    content = "柱哥和凤姐"
    name = "robot"
    FE = FalseEmail()
    FE.send_email(name, content)
